//	ID : pallab81
// 	PROG : 10054
// 	LANG : C++
// 	2011-07-10-00.38.34 Sunday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( X , VALUE ) memset( X , VALUE , sizeof(X) )

const int color = 50;
int total_nodes;
int edges[ color+10 ];
int adj[ color+10 ][ color+10 ];
string feed;

inline int isEular(){
    int i;
    for(i=1;i<=50;++i){
        if( edges[ i ]==0 )continue;
        if( (edges[ i ]&1 )!=0 )return -1;
    }
return 1;
}
inline void build_circuit(int now_node ){
        int i;
        for(i=1;i<=50;++i){
            if( adj[ now_node ][ i ]>0 ){
                adj[ now_node ][ i ]--;
                adj[ i ][ now_node ]--;
                build_circuit( i );
                printf("%d %d\n",i,now_node);
            }
        }
}

inline void doit(int cases){
    scanf("%d",&total_nodes);
    SET(edges, 0 );
    SET( adj, 0);
    int now_node = 100;
    fo(i,total_nodes){
        int x,y;
        scanf("%d %d",&x,&y);
        now_node = min( now_node, min(x,y) );
        edges[ x ]++;
        edges[ y ]++;
        adj[ x ][ y ]++;
        adj[ y ][ x ]++;
    }
    printf("%s",feed.c_str());
    printf("Case #%d\n",cases);
    if(isEular()==-1){
        printf("some beads may be lost\n");
    }
    else{
        build_circuit( now_node);
    }
    feed="\n";
}

int main(){
    int cases,i;
    feed="";
    scanf("%d",&cases);
    for(i=1 ;  cases-- ; ++i){
        doit(i);
    }

return 0;
}

